package servlet;

import javabean.Factory;


public class BookDeleteScoreOrCommentServlet extends BaseServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = -8538076142868886263L;
	
	public void service() throws Exception{
		String uid = (String)request.getSession().getAttribute("uid");
		String bid = request.getParameter("bid");
		String bcid = request.getParameter("bcid");
		if(uid!=null){
			if(bid!=null && !"".equals(bid)){
				try{
					if(Factory.getBookDAOInstance().deleteBookScore(bid, uid)){
						response.getWriter().write("{\"isLogin\":true,\"success\":true,\"msg\":\"删除成功\"}");
					}else{
						response.getWriter().write("{\"isLogin\":true,\"success\":false,\"msg\":\"删除失败\"}");
					}
				}catch(Exception ex){
					System.out.println("数据库出错了");
				}
			}else if(bcid!=null && !"".equals(bcid)){
				try{
					if(Factory.getBookDAOInstance().deleteBookComment(bcid)){
						response.getWriter().write("{\"isLogin\":true,\"success\":true,\"msg\":\"删除成功\"}");
					}else{
						response.getWriter().write("{\"isLogin\":true,\"success\":false,\"msg\":\"删除失败\"}");
					}
				}catch(Exception ex){
					System.out.println("数据库出错了");
				}
			}
		}else{
			response.getWriter().write("{\"isLogin\":false,\"success\":false,\"msg\":\"你还未登陆\"}");
		}
	}
}
